package ModLayer;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * Write a description of class LeaseCon here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LeaseCon
{
    public static LeaseCon instance;
    private ArrayList<Lease> leaseList;
    private Lease lease;

    private LeaseCon()
    {
        leaseList = new ArrayList<Lease>();
    }

    public static LeaseCon getInstance()
    {
        if(instance==null)
            instance = new LeaseCon();
        return instance;
    }

    public void createLease(String idProduct, String id, String idCustomer, String idEmployee, 
    String startDate, int duration)
    {
        lease = new Lease(idProduct, id, idCustomer, idEmployee, startDate, duration);
        leaseList.add(lease);
    }

    public void removeLease(String id)
    {
        leaseList.remove(findLease(id));
    }

    public Lease findLease(String id)
    {
        Lease returnsale = null;
        for(Lease x : leaseList)
        {
            if(id.equals(x.getID()))
            {
                returnsale = x;
            }
        }
        return returnsale;
    }
    
    public ArrayList<Lease> searchLease()
    {
        return leaseList;
    }
}